<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单列表</title>
    <meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0.maximum-scale=1.0,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="shopping/css/reset.css">
    <link rel="stylesheet" href="shopping/css/index.css">
    <link rel="stylesheet" href="shopping/css/flexible.css">
    <link rel="stylesheet" href="css/vant.css">
    <script src="js/jquery-3.3.1.min.js"></script>
    <script src="shopping/js/flexible.js"></script>
    <script src="js/vue/vue.js"></script>
    <script src="js/vue/axios.js"></script>
    <script src="js/vue/MD5.js"></script>
    <script src="js/vue/vant.js"></script>
</head>
<body class="order" style="padding-top:0rem;">
<div id="app">
    <div class="common clearfix height38 title_back">
        <a href="my.html" class="lf color0 shopping_left postion">
            <img class="shopping_left_img" src="shopping/images/baileft.png">
            <span class="back">返回</span>
        </a>
        订单列表
    </div>
    <template>
            <div class="order_message clearfix" style="padding-top:0.2rem;margin-top: 0.5rem" v-for="item in dataList">
                    <div class="clearfix">
                        <p class="order-time notPayTime lf">{{item.Datetime}}</p>
                        <p class="rf notPay" v-if="item.State=='0'" @click="pay(item.Ordernum)">去支付</p>
                        <p class="rf order-time" v-else-if="item.State=='1'">已支付</p>
                        <p class="rf order-time" v-else-if="item.State=='2'">已配货</p>
                        <p class="rf order-time" v-else-if="item.State=='3'">已自提</p>
                        <p class="rf order-time" v-else>已关闭</p>
                    </div>
                    <div class="order_list clearfix" v-for="(items,index) in item.GoodList">
                            <div class="left_order">
                                <img :src="items.Picurl">
                            </div>
                            <div class="right_order">
                                <p class="order_title">{{items.Goodsname}}</p>
                                <p class="bottom_content">
                                    <span class="price_Icon colors">￥</span><span class="details_price colors unitPrice">{{items.Price}}</span>
                                    <span class="rf add_order paddingright5">
                                        <span class="number" style="font-size:0.12rem;">x{{items.Num}}</span>
                                    </span>
                                </p>
                                <p class="all_order" v-if="index==item.GoodList.length-1">
                                        <span class="rf">
                                            <span>总价</span>
                                            <span class="price_Icon">￥</span><span class="details_price all_nuber">{{item.Price}}</span>
                                        </span>
                                        <span class="rf marginright02">
                                            <span>共&nbsp;</span><span class="number">{{item.Gnum}}</span><span>&nbsp;件商品</span>
                                        </span>
                                    </p>
                            </div>
                    </div>
                </div>
                <van-list
                    v-model="loading"
                    :finished="finished"
                    finished-text="没有更多了"
                    @load="onLoad"
                >
                <van-cell
                    v-for="item in lists"
                    :key="item"
                    :title="item"
                />
                </van-list>
    </template>
</div>
</body>
<script>
new Vue({
    el: '#app',
    data: {
       page:'',
       dataList:[],
       lists: [],
       loading: false,
       finished: false,
       totalnum:'',
       totalpage:'',
       listd:[]
    },
    created(){
       //this.getlists()
    },
    methods:{
        onLoad() {
            setTimeout(() => {
                 // 异步更新数据
                const params={
                    page:this.page
                }
                getVs()
                axios.get('/mobileapi/member/goods.php?act=orderlist',{params:params}).then(data =>{
                    console.log(data.data)
                    let { msg, code,user} = data.data
                        if (code !== 200) {
                            _this.$message({
                                message: msg,
                                type: 'error'
                            });
                        } else {
                            data=data.data
                            this.listd=data.data.list
                            this.totalnum=data.data.totalnum
                            for(let i in this.listd){
                                if(this.listd[i].Picurl==""||this.listd[i].Picurl==null){
                                    //alert("2")
                                    this.listd[i].Picurl='images/moren.png'
                                }
                            }
                            for (let i = 0; i < this.listd.length; i++) {
                                this.dataList.push(this.listd[i])
                            }
                            // 加载状态结束
                            this.loading = false
                            this.page=parseInt(data.data.page)+1
                            // 数据全部加载完成
                            if (this.dataList.length >= this.totalnum) {
                                this.finished = true
                            }
                        }
                    }).catch(function (error) {
                        console.log(error); 
                })
                console.log(this.listd)
            }, 500);
        },
        pay(ordernum){
            sessionStorage.setItem('ordernum',ordernum)
            let Gtoken=sessionStorage.getItem('token')
            const params2={
                ordernum:ordernum
            }
            axios.get('/mobileapi/member/goods.php?act=orderlistpay',{params:params2}).then(data =>{
                window.location.href=data.data.data.payurl+"&Bacurl=http%3a%2f%2ffitness.guanjialc.com%2fphone%2fmember%2fshopList.html"
            }).catch(function (error) {
                console.log(error);
            })
        }
    },
    beforeDestroy() {
        clearTimeout(this.timer)
        clearTimeout(this.timers)
    }
})
</script>
</html>